# Doclib Delete File Versions
Trims version history in a document library by deleting old minor or major versions beyond a configured maximum, by processing rows from an Excel file.
Filename pattern: filename must contain DoclibDeleteFileVersion (case-insensitive).
Example: 20240115 DoclibDeleteFileVersion trim.xlsx
# Columns
| Name | Required | Description |
|---|---|---|
| MatterCode | Conditional | Matter code used to resolve document libraries from the matter list. When provided, processes all document libraries for the matter. |
| ClientCode | No | Client code used together with MatterCode to identify the matter. |
| Url | Conditional | Server-relative URL of the document library or a folder/file path within it. Used when MatterCode is not provided. |
| Search | No | Search filter expression to limit which files are processed. |
| MaxMinorVersions / MaxMinorVersion | No | Maximum number of minor versions to retain per file. Versions beyond this limit (oldest first) are deleted. |
| MaxMajorVersions / MaxMajorVersion | No | Maximum number of major versions to retain per file. Versions beyond this limit (oldest first) are deleted. |
| DisableRecyclebin | No | Boolean. true permanently deletes versions instead of sending them to the recycle bin. Defaults to false. |
At least one of MatterCode or Url must resolve to a document library. If neither is provided, the handler processes no documents.
# Behavior
For each file in the library, the handler keeps at most the MaxMinorVersions most recent minor versions and at most the MaxMajorVersions most recent major versions. The current version is never deleted. Deleted versions are recycled unless DisableRecyclebin is true.
# Related links
- Doclib Versioning handler — configure versioning settings (enable/disable major and minor versions)